/*
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) :
            val(x), left(NULL), right(NULL) {
    }
};
*/
class Solution {
public:
    TreeNode* KthNode(TreeNode* pRoot, unsigned int k)
    {
        if(pRoot == nullptr || k == 0)
        	return nullptr;
        findCore(pRoot,k);
        return find;
    }
    void findCore(TreeNode *p,unsigned int k)
    {
    	if(p->left)
    		findCore(p->left,k);
    	++s;
    	if(s == k)
    		find = p;
    	if(p->right)
    		findCore(p->right,k);
    }
private:
	unsigned int s = 0;
	TreeNode *find = nullptr;
    
};